package yxy.game.pm2.command.temple;

import yxy.cherry.game.base.message.MessageEmitterHandler;
import yxy.cherry.game.base.message.annotation.MessageSource;
import yxy.cherry.game.base.message.annotation.MessageType;
import yxy.game.pm2.Result;
import yxy.game.pm2.command.Command;
import yxy.game.pm2.message.TempleMessage;
import yxy.game.pm2.module.temple.TempleHandle;

/** 置换神殿 七星祭坛 */
@MessageType(proto = Command.SevenStar, classtype = TempleMessage.SevenStarRequest.class)
public class CMD_SevenStar extends Command<TempleMessage.SevenStarRequest> {

	@Override
	public void execute(MessageSource messageSource, TempleMessage.SevenStarRequest request) {
		String playerCode = messageSource.getTag();

		TempleMessage.SevenStarResponse.Builder response = TempleMessage.SevenStarResponse.newBuilder();

		TempleHandle templeHandle = new TempleHandle();
		response.addAllHeros(templeHandle.sevenStarHeros(playerCode));

		send(messageSource, response, Result.Success);
	}

	private void send(MessageSource messageSource, TempleMessage.SevenStarResponse.Builder response, Result result) {
		response.setResult(result.packResult());
		MessageEmitterHandler.getInstance().send(messageSource, response.build());
	}
}